<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const pig = {
        name: "佩奇",
        family: {
          mother: "猪妈",
          father: "猪爸",
          sister: "乔治",
        },
      };
      // 解构
      const {
        name,
        family: { mother, father, sister },
      } = pig; // 加对象名 family 解构对象
      console.log(name);
      console.log(mother);
      console.log(father);
      console.log(sister);
    </script>
  </body>
</html>
